#include "RbnEmbryoGenome.h"

#include "../../../physics/cpm/RbnCellController.h"

namespace GA {

/*
	RbnEmbryoGenome
*/

/*	public	*/

RbnEmbryoGenome::~RbnEmbryoGenome() {
	/* RBN genome */
	delete _rbnGenome;
}

RbnEmbryoGenome* RbnEmbryoGenome::newRandom() {
	/* new genome */
//	return new RbnEmbryoGenome(RbnGenome::newRandom(0, 70, 2));
	return new RbnEmbryoGenome(RbnGenome::newRandom(0, 28, 2));
}

Genome* RbnEmbryoGenome::copy() const {
	/* new genome */
	return new RbnEmbryoGenome(*this);
}

Genome* RbnEmbryoGenome::crossover(Genome const& genome) const {
	/* partner */
	RbnEmbryoGenome const& partner = static_cast<RbnEmbryoGenome const&>(genome);

	/* new offspring */
	return new RbnEmbryoGenome(static_cast<GA::RbnGenome*>(_rbnGenome->crossover(*(partner._rbnGenome))));
}

void RbnEmbryoGenome::mutate(double geneMutationProbability) {
	_rbnGenome->mutate(geneMutationProbability);
}

CellController* RbnEmbryoGenome::getNewCellController() const {
	return new RbnCellController(_rbnGenome->getNewRbn());
}

/*	private	*/

RbnEmbryoGenome::RbnEmbryoGenome(RbnGenome* rbnGenome) :
	_rbnGenome(rbnGenome) {}

RbnEmbryoGenome::RbnEmbryoGenome(RbnEmbryoGenome const& genome) :
	EmbryoGenome(),
	_rbnGenome(new RbnGenome(*(genome._rbnGenome))) {}

} // GA

